<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>日期类型</title>
    <script>
        function f1(){
            // 当前时间
            let date = new Date();
            console.log(date)
            // 构造函数的参数顺序为:年、月、日、时、分、秒、毫秒
            // 月份取值范围:0-11表示1-12月
            // 未赋值的部分全部初始值
            let date2 = new Date(2025,2-1);
            console.log(date2);
            // 构造方法的参数可以是毫秒数
            let date3 = new Date(date.getTime());
            console.log(date3)
        }
        function f2(){
            let date = new Date();
            console.log("年份:"+date.getFullYear())
            console.log("月份:"+(date.getMonth() + 1))
            console.log("天数:"+date.getDate())
            console.log("小时数:"+date.getHours())
            console.log("分钟数:"+date.getMinutes())
            console.log("秒数:"+date.getSeconds())
            console.log("毫秒数:"+date.getMilliseconds())
            console.log(date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日"+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds())
        }
        function f3(){
            let date = new Date();
            date.setFullYear(2024);
            date.setMonth(1);
            date.setDate(30);
            date.setHours(10);
            date.setMinutes(10);
            date.setSeconds(10);
            console.log(date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日"+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds())

        }
    </script>
</head>
<body>
<button onclick="f1()">定义方式</button><br>
<button onclick="f2()">取值方法</button><br>
<button onclick="f3()">赋值方法</button>
</body>
</html>